package com.web.dao;

import com.web.entity.PoundageConfig;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author FDjavaone
 */
public class PoundageConfigSqlProvider {


    public String insertSelective(PoundageConfig record) {
        BEGIN();
        INSERT_INTO("t_poundage_config");

        if (record.getProfitWithdraw() != null) {
            VALUES("profit_withdraw", "#{profitWithdraw,jdbcType=DECIMAL}");
        }

        if (record.getProfitTransfer() != null) {
            VALUES("profit_transfer", "#{profitTransfer,jdbcType=DECIMAL}");
        }

        if (record.getMerchantWithdraw() != null) {
            VALUES("merchant_withdraw", "#{merchantWithdraw,jdbcType=DECIMAL}");
        }

        if (record.getMskSale() != null) {
            VALUES("msk_sale", "#{mskSale,jdbcType=DECIMAL}");
        }

        if (record.getMskSaleP() != null) {
            VALUES("msk_sale_p", "#{mskSaleP,jdbcType=DECIMAL}");
        }

        if (record.getMskSaleC() != null) {
            VALUES("msk_sale_c", "#{mskSaleC,jdbcType=DECIMAL}");
        }

        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }

        return SQL();
    }


    public String updateByPrimaryKeySelective(PoundageConfig record) {
        BEGIN();
        UPDATE("t_poundage_config");

        if (record.getProfitWithdraw() != null) {
            SET("profit_withdraw = #{profitWithdraw,jdbcType=DECIMAL}");
        }

        if (record.getProfitTransfer() != null) {
            SET("profit_transfer = #{profitTransfer,jdbcType=DECIMAL}");
        }

        if (record.getMerchantWithdraw() != null) {
            SET("merchant_withdraw = #{merchantWithdraw,jdbcType=DECIMAL}");
        }

        if (record.getMskSale() != null) {
            SET("msk_sale = #{mskSale,jdbcType=DECIMAL}");
        }

        if (record.getMskSaleP() != null) {
            SET("msk_sale_p = #{mskSaleP,jdbcType=DECIMAL}");
        }

        if (record.getMskSaleC() != null) {
            SET("msk_sale_c = #{mskSaleC,jdbcType=DECIMAL}");
        }

        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=BIGINT}");

        return SQL();
    }


}